
//
// 110409 - AH - Created.
// 

package org.soekrat.engine.pitbul.generator;

import java.io.IOException;
import java.io.PrintWriter;

import org.soekrat.engine.Soekrat2Engine;

/**
 * <p>
 *   Base class for objects that generate Pitbul code for a form. 
 * </p>
 * @author Arne Halvorsen (AH)
 */
public abstract class FormGenerator 
{
  private final String m_form;
  
  /**
   * <p>
   *   Constructor.
   * </p>
   * @param form Bame on form {@code this} generate code for.
   */
  protected FormGenerator(String form)
  {
    if (form==null)
    {
      throw new NullPointerException("form");
    }
    
    m_form=form;
  }

  /**
   * <p>
   *   Gets name on form {@code this} generate code for.
   * </p>
   * @return Name.
   */
  public String getForm(){ return m_form; }

  /**
   * <p>
   *   Generate Pitbul code.
   * </p>
   * @param se {@link Soekrat2Engine}.
   * @param pw Stream to write code to.
   * @throws IOException If fails.
   */
  public abstract void generate(Soekrat2Engine se, PrintWriter pw) 
    throws IOException;
  
  /**
   * <p>
   *   The empty array shared.
   * </p>
   */
  public static final FormGenerator[] EMPTY_ARRAY=new FormGenerator[0];
  
}
